package org.spring.learn.demo.annotation.configures.conditional;

import org.spring.learn.project.entity.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyConfig {

    @Conditional(WinConditional.class)
    @Bean
    public Person tom(){
        System.out.println("将对象tom添加到Ioc容器中");
        // 控制权反转
        return new Person("tom",21);
    }
    @Conditional(LinuxConditional.class)
    @Bean
    public Person lisa(){
        System.out.println("将对象lisa添加到Ioc容器中");
        // 控制权反转
        return new Person("lisa",18);
    }
    @Conditional(WinConditional.class)
    @Bean
    public Person james(){
        System.out.println("将对象james添加到Ioc容器中");
        // 控制权反转
        return new Person("james",18);
    }

}
